$(function () {
    $("#jqGrid").jqGrid({
        datatype:'json',
        url: baseURL + 'sys/transactionInfo/logList',
        colModel: [
			{ label: '日志id', name: 'logTranId', index: "transactionId", width: 45, key: true,align:'center', sortable: false },
			{ label: '日志信息', name: 'explainsInfo', width: 75,align:'center', sortable: false },
			{ label: '导入时间', name: 'createDate', width: 75,align:'center', sortable: true},
            { label: '交易笔数', name: 'totalNumber', width: 100,align:'center', sortable: false},
            { label: '交易总额', name: 'totalTransaction', width: 100,align:'center', sortable: false},
            { label: '状态', name: 'logStates', width:65,formatter:function (value,option,row) {
                    if(value=='FAIL'){
                        return '<label style="color: red;">FAIL</label>';
                    }
                    return value;
                }, sortable: false},
            { label: '登录用户', name: 'userName', width: 75,align:'center', sortable: false},

			{ label: '是否显示', name: 'isShow', width: 75,align:'center',formatter:function(value,options,row){
                    return value==1?"是":"否";
                }, sortable: false},
        ],
		viewrecords: true,
        height: 420,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth:true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount",

        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    }).setGridParam();

bindType();
});

var setting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "deptId",
            pIdKey: "parentId",
            rootPId: -1
        },
        key:{
            url:"nourl"
        }
    }
};


var vm = new Vue({
    el:'#rrapp',
    data:{
        q:{
            createDate:null,
            logStates:"",
            terminalType:0
        },
        showList: true,
        showAdd:false,
        addById:false,
        title:null,
        terminalTypes:[],
    },
    methods: {
        query: function () {
            vm.reload();
        },
        clean:function(){
            vm.showList = true;
            vm.q={
                createDate:null,
                logStates:"",
                terminalType:0
            };
            $("#startDate").val("");
            $("#jqGrid").jqGrid('setGridParam',0);
            vm.reload();
        },
        reload: function () {
            vm.showList = true;
            vm.showAdd=false;
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            vm.q.createDate=$("#startDate").val();
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{'logStates': vm.q.logStates,'createDate':vm.q.createDate,"terminalType":vm.q.terminalType},
                page:page,
            }).trigger("reloadGrid");
        }
    }
});
function bindType() {

        $.getJSON(baseURL + "sys/terminalType/list", function (r) {
            vm.$set(vm.terminalTypes, 0, {
                terminalType: 0,
                terminalName: "请选择类型"
            });
            for (var i = 0; i < r.page.length; i++) {
                vm.$set(vm.terminalTypes, (i + 1), r.page[i]);
            }
            vm.q.terminalType=0;
        })


}

